<template>
  <navbar title="团报" :isBack="true"></navbar>
  <loading v-if="!info"></loading>
  <template v-else>
    <view class="header flex-direction-column">
      <image mode="aspectFill" :src="info.cover"></image>
      <view class="title">{{ info.name }}</view>
      <view class="desc flex-direction-column">
        <view class="time">{{ info.club_name }}</view>
        <!-- <view class="item"> 赛事地点：{{ info.province }}·{{ info.city }} </view>
        <view class="item">赛事时间：{{ info.start_time }}</view> -->
      </view>
    </view>
    <view class="line"></view>
    <view class="middle flex-direction-column">
      <view class="xh flex-direction-column">
        <!-- <image src="/static/icon/19.png"></image> -->

        <text>赛事地点：{{ info.province }}·{{ info.city }} </text>
        <text>赛事时间：{{ info.start_time }}</text>
      </view>
      <view class="title">团报名称：{{ info.name }}</view>
      <view class="pass flex">
        <image src="/static/icon/23.png"></image>
        <view class="shu"></view>
        <input placeholder="请输入密码" placeholder-style="color:#CCCCCC" v-model="params.password" />
      </view>
    </view>
    <view class="line"></view>
    <view class="rich flex-direction-column">
      <view class="title">详情</view>
      <view class="parse">
        <u-parse :html="info.detail"></u-parse>
      </view>
    </view>
    <view class="btn flex-center" @click="go">
      <text>进入团报</text>
    </view>
  </template>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getTeam, getCheckPwd } from '@/service/api/index'
import tools from '@/utils/tools'

let info = ref(null)
let params = ref({
  id: '',
  password: ''
})

// 团报页面
const getTeamApi = async () => {
  const { msg } = await getTeam({ id: params.value.id })
  info.value = msg
  console.log(msg)
}

// 核对密码
const getCheckPwdApi = async () => {
  if (tools.isObjEmpty(params.value)) return tools.showToast('请填写密码')
  const { code, msg } = await getCheckPwd(params.value)
  if (code == 0) return tools.showToast(msg)
  tools.navTo('/pagesA/group/entry?id=' + params.value.id)
}

// 进入团报
const go = () => {
  getCheckPwdApi()
}

onLoad((option) => {
  params.value.id = decodeURIComponent(option.scene)
  // 团报页面
  getTeamApi()
})
</script>

<style lang="scss" scoped>
.header {
  margin: 0 26rpx;
  padding-bottom: 30rpx;
  // border-bottom: 1px solid #eee;
  image {
    width: 100%;
    height: 380rpx;
    border-radius: 10rpx;
  }
  .title {
    font-size: 32rpx;
    font-weight: bold;
    line-height: 44rpx;
    margin-top: 26rpx;
  }
  .desc {
    color: #999999;
    font-size: 24rpx;
    margin-top: 16rpx;
    line-height: 40rpx;
  }
}
.middle {
  margin: 20rpx 26rpx 0 26rpx;
  .xh {
    image {
      width: 22rpx;
      height: 22rpx;
      margin-right: 10rpx;
    }
    text {
      height: 40rpx;
      font-size: 28rpx;
      color: #777777;
    }
  }
  .title {
    margin-top: 16rpx;
    font-size: 32rpx;
    font-weight: bold;
    line-height: 44rpx;
  }
  .pass {
    padding: 30rpx 26rpx;
    margin-bottom: 30rpx;
    margin-top: 38rpx;
    border-radius: 10rpx;
    border: 1px solid #eeeeee;
    image {
      width: 28rpx;
      height: 34rpx;
      margin-top: -5rpx;
    }
    .shu {
      width: 2rpx;
      height: 28rpx;
      margin: 0 30rpx;
      background-color: #eeeeee;
    }
  }
}
.rich {
  .title {
    width: 100%;
    text-align: center;
    padding: 28rpx 280rpx;
    border-bottom: 1px solid #eee;
  }
  .parse {
    margin: 28rpx 26rpx 0 26rpx;
    padding-bottom: 160rpx;
  }
}
.btn {
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 160rpx;
  position: fixed;
  text {
    color: #fff;
    width: 700rpx;
    height: 100rpx;
    line-height: 100rpx;
    margin-top: 6rpx;
    font-size: 32rpx;
    text-align: center;
    background: rgba(230, 66, 94);
    border-radius: 6rpx;
  }
}
</style>
